package com.xuduo.amd.util;

import java.util.HashMap;
import java.util.Map;

public class TlifebeContextUtils {
    private static InheritableThreadLocal<Map<String, String>> context = new InheritableThreadLocal<>();

    public static void setEntrance(String entrance) {
        getValueMap().put("entrance", entrance);
    }
    public static String getEntrance() {
        Map<String, String> values = context.get();
        if (values != null)
            return values.get("entrance");
        return null;
    }

    public static void setUserId(String userId) {
        getValueMap().put("userId", userId);
    }

    public static String getUserId() {
        Map<String, String> values = context.get();
        if (values != null)
            return values.get("userId");
        return null;
    }

    public static void setAppId(String userId) {
        getValueMap().put("userId", userId);
    }

    public static String getAppId() {
        Map<String, String> values = context.get();
        if (values != null)
            return values.get("AppId");
        return null;
    }

    public static void setNickname(String nickname) {
        getValueMap().put("nickname", nickname);
    }

    public static String getNickname() {
        Map<String, String> values = context.get();
        if (values != null)
            return values.get("nickname");
        return null;
    }

    public static void setUacId(String uacId) {
        getValueMap().put("uacId", uacId);
    }

    public static String getUacId() {
        Map<String, String> values = context.get();
        if (values != null)
            return values.get("uacId");
        return null;
    }

    public static void setTraceId(String traceId) {
        getValueMap().put("traceId", traceId);
    }
    public static String getTraceId() {
        Map<String, String> values = context.get();
        if (values != null)
            return values.get("traceId");
        return null;
    }



    public static void setStarTime(String starTime) {
        getValueMap().put("starTime", starTime);
    }
    public static String getStarTime() {
        Map<String, String> values = context.get();
        if (values != null)
            return values.get("starTime");
        return null;
    }

    public static void setControllerMethod(String controllerMethod) {
        getValueMap().put("controllerMethod", controllerMethod);
    }

    public static String getControllerMethod() {
        Map<String, String> values = context.get();
        if (values != null)
            return values.get("controllerMethod");
        return null;
    }


    public static void setHttpMethod(String httpMethod) {
        getValueMap().put("httpMethod", httpMethod);
    }

    public static String getHttpMethod() {
        Map<String, String> values = context.get();
        if (values != null)
            return values.get("httpMethod");
        return null;
    }

    public static void setDeciveIp(String deciveIp) {
        getValueMap().put("deciveIp", deciveIp);
    }

    public static String getDeciveIp() {
        Map<String, String> values = context.get();
        if (values != null)
            return values.get("deciveIp");
        return null;


    }

    public static void setUserRole(String userRole) {
        getValueMap().put("userRole", userRole);
    }

    public static String getUserRole() {
        Map<String, String> values = context.get();
        if (values != null)
            return values.get("userRole");
        return null;
    }

    private static Map<String, String> getValueMap() {
        Map<String, String> values = context.get();
        if (values == null) {
            values = new HashMap<String, String>();
            context.set(values);
        }
        return values;
    }

//    以下取这些公共参数

    public static void setDeviceId(String deviceId) {
        getValueMap().put("deviceId", deviceId);
    }

    public static String getDeviceId() {
        Map<String, String> values = context.get();
        if (values != null)
            return values.get("deviceId");
        return null;
    }

    public static void setDeviceType(String deviceType) {
        getValueMap().put("deviceType", deviceType);
    }

    public static String getDeviceType() {
        Map<String, String> values = context.get();
        if (values != null)
            return values.get("deviceType");
        return null;
    }

    public static void setDeviceVersion(String deviceVersion) {
        getValueMap().put("deviceVersion", deviceVersion);
    }

    public static String getDeviceVersion() {
        Map<String, String> values = context.get();
        if (values != null)
            return values.get("deviceVersion");
        return null;
    }

    public static void setAppVersion(String appVersion) {
        getValueMap().put("appVersion", appVersion);
    }

    public static String getAppVersion() {
        Map<String, String> values = context.get();
        if (values != null)
            return values.get("appVersion");
        return null;
    }


    public static void setDeviceModel(String deviceModel) {
        getValueMap().put("deviceModel", deviceModel);
    }

    public static String getDeviceModel() {
        Map<String, String> values = context.get();
        if (values != null)
            return values.get("deviceModel");
        return null;
    }

    public static void setMobile(String mobile) {
        getValueMap().put("mobile", mobile);
    }

    public static String getMobile() {
        Map<String, String> values = context.get();
        if (values != null)
            return values.get("mobile");
        return null;
    }


    public static void setUserName(String userName) {
        getValueMap().put("userName", userName);
    }

    public static String getUserName() {
        Map<String, String> values = context.get();
        if (values != null)
            return values.get("userName");
        return null;
    }

    public static void setCertificateType(String certificateType) {
        getValueMap().put("certificateType", certificateType);
    }

    public static String getCertificateType() {
        Map<String, String> values = context.get();
        if (values != null)
            return values.get("certificateType");
        return null;
    }


    public static void setCertificateCode(String certificateCode) {
        getValueMap().put("certificateCode", certificateCode);
    }

    public static String getCertificateCode() {
        Map<String, String> values = context.get();
        if (values != null)
            return values.get("certificateCode");
        return null;
    }

    public static void setGender(String gender) {
        getValueMap().put("gender", gender);
    }

    public static String getGender() {
        Map<String, String> values = context.get();
        if (values != null)
            return values.get("gender");
        return null;
    }


    public static void setBirthday(String birthday) {
        getValueMap().put("birthday", birthday);
    }

    public static String getBirthday() {
        Map<String, String> values = context.get();
        if (values != null)
            return values.get("birthday");
        return null;
    }


    public static void setPartyId(String partyId) {
        getValueMap().put("partyId", partyId);
    }

    public static String getPartyId() {
        Map<String, String> values = context.get();
        if (values != null)
            return values.get("partyId");
        return null;
    }


    public static String getAllAsString(){
        Map<String, String> values = context.get();
        if (values != null)
            return null;
        return values.toString();
    }

    public static void cleanAll(){
        context.set(null);
    }

}
